package com.baizhi.springboot.service.impl;

import com.baizhi.springboot.dao.ReserveDao;
import com.baizhi.springboot.entity.Inform;
import com.baizhi.springboot.entity.Reserve;
import com.baizhi.springboot.service.ReserveService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class ReserveServiceImpl implements ReserveService {
    @Autowired
    private ReserveDao reserveDao;
    @Override
    public Map selectReserveByPage(Integer page, Integer limit,Reserve reserve) {
        Integer offset=(page-1)*limit;
        List<Reserve> reserves = reserveDao.selectReserveByPage(offset, limit,reserve);
        Integer count = reserveDao.selectCount();
        /* "code": 0,
          "msg": "",
          "count": 1000,
          "data": [{}, {}]*/
        HashMap<Object, Object> map = new HashMap<>();
        map.put("code", 0);
        map.put("msg", "");
        map.put("count", count);
        map.put("data", reserves);
        return map;
    }

    @Override
    public void insertReserve(Reserve reserve) {
        reserveDao.insertReserve(reserve);
    }

    @Override
    public void deleteReserve(Integer id) {
        reserveDao.deleteReserve(id);
    }

    @Override
    public Reserve selectOneReserve(Integer id) {
        return reserveDao.selectOneReserve(id);
    }

    @Override
    public void updateReserve(Reserve reserve) {
        reserveDao.updateReserve(reserve);
    }
}
